/*
 * @Author: wuqingchun
 * @Date: 2024-07-23 13:24:30
 * @Description: 线程缓存类
 * @LastEditors: wuqingchun
 * @LastEditTime: 2024-07-23 20:35:05
 */
#ifndef __THREAD_CACHE_H__
#define __THREAD_CACHE_H__

#include <cstddef>
#include <cassert>

#include "common.h"

/**
 * @brief 线程缓存类
 * 每个线程会有一个该类的对象，从该类中申请内存不存在竞争
 * 
 */
class ThreadCache
{
public:
    void* Alloc(size_t ulSize);
    void Free(void* pMem);
private:
    void* __AllocFromCCache(size_t ulIndex, size_t ulSize);
private:
    FreeList m_arrFreeList[SizeAlignStrategy::NR_FREELIST];
};

#endif //__THREAD_CACHE_H__